package org.liveboardgames.agricola.control.delegates.mock.cards.actioncards
{
	import org.liveboardgames.agricola.control.delegates.mock.ActionFactory;
	import org.liveboardgames.agricola.model.enums.ActionOutputEnum;
	import org.liveboardgames.agricola.model.enums.HouseTypeEnum;
	import org.liveboardgames.agricola.model.enums.PrerequisiteActionTypeEnum;
	import org.liveboardgames.agricola.model.enums.ResourceZoneEnum;
	import org.liveboardgames.agricola.view.component.ImageHandler;
	import org.liveboardgames.agricola.vo.action.Action;
	import org.liveboardgames.agricola.vo.card.ActionCard;
	
	import mx.collections.ArrayCollection;
	import mx.collections.ListCollectionView;

	public class PeriodTwoCards
	{
		public static const BIRTH_THEN_MINOR_IMPROVEMENT:ActionCard = getBirthThenMinorImpCard();
		public static const RENOVATION_THEN_IMPROVEMENT:ActionCard = getRenovThenImpCard();
		public static const ONE_STONE:ActionCard = getOneStoneCard();

		private static function getBirthThenMinorImpCard():ActionCard
		{
			var card:ActionCard = new ActionCard();
			card.imagePath = ImageHandler.ACTIONS + "BirthThenMinorImprovement.png";
			card.cardName = "Birth than Minor Improvement card";

			// Build the actions
			var actions:ArrayCollection = new ArrayCollection();

			// Birth
			var birth:Action = ActionFactory.getBirthAction();
			birth.link = card;
			actions.addItem(birth);

			card.actions = actions;
			return card;
		}

		private static function getRenovThenImpCard():ActionCard
		{
			var card:ActionCard = new ActionCard();
			card.cardName = "Renovation then improvement";
			card.imagePath = ImageHandler.ACTIONS + "RenovationThenImprovement.png";

			// Build the actions
			var actions:ArrayCollection = new ArrayCollection();

			// Renovation
			var renovToClayAction:Action = ActionFactory.getRenovationAction(HouseTypeEnum.CLAY);
			var renovToStoneAction:Action = ActionFactory.getRenovationAction(HouseTypeEnum.STONE);

			// Improvement
			var improvAction:Action = ActionFactory.getMajorImprovementAction();
			improvAction.addPrerequisiteAction(renovToClayAction);
			improvAction.addPrerequisiteAction(renovToStoneAction);
			// If any of the two previous action has been done, this is ok
			improvAction.prerequisiteActionType = PrerequisiteActionTypeEnum.ANY;

			actions.addItem(renovToClayAction);
			actions.addItem(renovToStoneAction);
			actions.addItem(improvAction);

			card.actions = actions;

			var exclusiveActions:ListCollectionView = new ArrayCollection();
			exclusiveActions.addItem(renovToClayAction);
			exclusiveActions.addItem(renovToStoneAction);
			card.exclusiveActions = exclusiveActions;

			return card;
		}

		private static function getOneStoneCard():ActionCard
		{
			var card:ActionCard = new ActionCard();
			card.imagePath = ImageHandler.ACTIONS + "OneStone.png";
			card.cardName = "One stone (period 2) card";
			card.resourceZone = ResourceZoneEnum.BOTTOM;

			// Build the actions
			var actions:ArrayCollection = new ArrayCollection();
			var action:Action = ActionFactory.getResourceAction(ActionOutputEnum.STONE, 1, true);
			action.target = card;
			action.needPlayerInput = false;
			
			// A peep can take all accumulated resources
			var takeAction:Action = ActionFactory.getTakeAllAction(card);
			
			actions.addItem(action);
			actions.addItem(takeAction);

			card.actions = actions;
			return card;
		}
	}
}